﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/Admin.master" AutoEventWireup="true" CodeFile="Admin_QL_VOURCHER.aspx.cs" Inherits="Admin_Admin_QL_VOURCHER" %>

<asp:Content ID="Content1" ContentPlaceHolderID="NoiDung" Runat="Server">

        <table align="left" cellpadding="0" cellspacing="0" width="500">
            <tr>
                <td width="100" align="left">
                    Mã:</td>
                <td width="400" align="left">
                    <asp:TextBox ID="txtMa" runat="server"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                        ControlToValidate="txtMa" ErrorMessage="*"></asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td width="100" align="left">
                    Giá trị:</td>
                <td width="400" align="left">
                    <asp:TextBox ID="txtGiaTri" runat="server"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                        ControlToValidate="txtGiaTri" ErrorMessage="*" Display="Dynamic"></asp:RequiredFieldValidator>
                <asp:RegularExpressionValidator ID="RegularExpressionValidator4" runat="server" 
                    ControlToValidate="txtGiaTri" 
                    ErrorMessage="Giá trị có dạng số" ValidationExpression="[\d]+"></asp:RegularExpressionValidator>
                </td>
            </tr>
        </table>
        <br />
        <div>
            <asp:Button ID="btnThem" runat="server" Text="Thêm" CausesValidation="False" 
                onclick="btnThem_Click" />
            <asp:Button ID="btnLuu" runat="server" Text="Lưu" onclick="btnLuu_Click" />
        </div>
        

    <br />
    <asp:GridView ID="GridViewVourcher" runat="server" AllowPaging="True" 
        AutoGenerateColumns="False" CellPadding="4" DataKeyNames="idVourcher" 
        DataSourceID="SqlDataSource1" 
        EmptyDataText="There are no data records to display." ForeColor="#333333" 
        GridLines="None" Width="750px">
        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
        <Columns>
            <asp:BoundField DataField="idVourcher" ReadOnly="True" 
                SortExpression="idVourcher" Visible="False" />
            <asp:BoundField DataField="maVourcher" HeaderText="Mã số" 
                SortExpression="maVourcher">
            <ItemStyle Width="40%" />
            </asp:BoundField>
            <asp:BoundField DataField="giaTri" DataFormatString="{0:#,###}" 
                HeaderText="Giá trị" SortExpression="giaTri">
            <ItemStyle Width="40%" />
            </asp:BoundField>
            <asp:CommandField ButtonType="Image" CancelImageUrl="~/Hinh/Cancel.jpg" 
                DeleteImageUrl="~/Hinh/Delete.jpg" EditImageUrl="~/Hinh/Edit.png" 
                InsertImageUrl="~/Hinh/Save.jpg" NewImageUrl="~/Hinh/New.jpg" 
                ShowDeleteButton="True" ShowEditButton="True" UpdateImageUrl="~/Hinh/Save.jpg">
            <ItemStyle Width="20%" />
            </asp:CommandField>
        </Columns>
        <EditRowStyle BackColor="#999999" />
        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
        <SortedAscendingCellStyle BackColor="#E9E7E2" />
        <SortedAscendingHeaderStyle BackColor="#506C8C" />
        <SortedDescendingCellStyle BackColor="#FFFDF8" />
        <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:BookIdeas_ShopConnectionString %>" 
        DeleteCommand="DELETE FROM [Vourcher] WHERE [idVourcher] = @idVourcher" 
        InsertCommand="INSERT INTO [Vourcher] ([maVourcher], [giaTri]) VALUES (@maVourcher, @giaTri)" 
        ProviderName="<%$ ConnectionStrings:BookIdeas_ShopConnectionString.ProviderName %>" 
        SelectCommand="SELECT [idVourcher], [maVourcher], [giaTri] FROM [Vourcher]" 
        UpdateCommand="UPDATE [Vourcher] SET [maVourcher] = @maVourcher, [giaTri] = @giaTri WHERE [idVourcher] = @idVourcher">
        <DeleteParameters>
            <asp:Parameter Name="idVourcher" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="maVourcher" Type="String" />
            <asp:Parameter Name="giaTri" Type="Double" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="maVourcher" Type="String" />
            <asp:Parameter Name="giaTri" Type="Double" />
            <asp:Parameter Name="idVourcher" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
</asp:Content>

